package com.xianyu.lht.Contorller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xianyu.lht.Mapper.UserMapper;
import com.xianyu.lht.POJO.Result;
import com.xianyu.lht.POJO.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/user")
public class UserContorller {
    @Autowired
    private UserMapper um;

    /**
     *
     * @param
     * @param
     * @return
     */
    @PostMapping("/login")
    public Result login(@RequestBody User user){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", user.getUsername());
        User user1 = um.selectOne(queryWrapper);
        if (user1 != null && user1.getPassword().equals(user.getPassword())){
            return Result.success();
        } else {
            return Result.error("登录失败");
        }
    }
}
